<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <css file="__PUBLIC__/css/base.css"/>
            <link type="text/css" href="__ROOT__/data/ui/css/flick/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
            <script type="text/javascript" src="__ROOT__/data/ui/js/jquery-1.8.0.min.js"></script>
            <script type="text/javascript" src="__ROOT__/data/ui/js/jquery-ui-1.8.23.custom.min.js"></script>
            <script src="__DATA__/validate.min.js" language="javascript"></script>
			<script type="text/javascript">
                $(function(){
                    $("#tabs").tabs();
                })
            </script>
    </head>
    <body>
        <div class="now_path">
            <strong>您现在的位置：</strong>
            <a href="#">网站配置管理</a><span>></span>
        </div>
		<div class="success_box">所有的选项都填写正确</div>
    	<div class="error_box"></div>
        <div id="tabs" style="width:100%">
            <ul>
                <li><a href="#tabs-1">添加配置项</a></li>
            </ul> 
			<form action="__CONTROL__/config_modify_exe" method="post" name='config'>
            <div id="tabs-1">
            	<table class="table2">
            		<tr>
            			<th>所属配置组</th>
						<td>
							<select name='tid'>
								<option value=''>--请选择配置组--</option>
								<list from='$con_type' name='$v'>
									<if value='$config.tid eq $v.tid'>
									<option value='{$v.tid}' selected='selected'>{$v.tname}</option>
									<else />
									<option value='{$v.tid}'>{$v.tname}</option>
									</if>
								</list>
							</select>
							<span class="desc"><font color="#737C93">前台显示形式</font></span>
						</td>
            		</tr>
					<tr>
            			<th>配置名称</th>
						<td>
							<input type='text' name='name' value='{$config.name}'/>
							<span class="desc"><font color="#737C93">必须是英文或拼音</font></span>
						</td>
            		</tr>
					<tr>
            			<th>标题</th>
						<td>
							<input type='text' name='title' value='{$config.title}'/>
							<span class="desc"><font color="#737C93">配置项提示文字，中文更好</font></span>
						</td>
            		</tr>
					<tr>
            			<th>配置类型</th>
						<td>
							<select name='viewtype'>
								<if value='$config.viewtype eq "string"'>
									<option value='string' selected='selected'>文本框</option>
								<else />
									<option value='string'>文本框</option>
								</if>
								<if value='$config.viewtype eq "select"'>
									<option value="select" selected='selected'>下拉列表框</option>
								<else />
									<option value="select">下拉列表框</option>
								</if>
								<if value='$config.viewtype eq "radio"'>
									<option value="radio" selected='selected'>单选框</option>
								<else />
									<option value="radio">单选框</option>
								</if>
								<if value='$config.viewtype eq "checkbox"'>
									<option value="checkbox" selected='selected'>复选框</option>
								<else />
									<option value="checkbox">复选框</option>
								</if>
								<if value='$config.viewtype eq "textarea"'>
									<option value="textarea" selected='selected'>复选框</option>
								<else />
									<option value="textarea">文本区域</option>
								</if>
							</select>
							<span class="desc"><font color="#737C93">前台显示形式</font></span>
						</td>
            		</tr>
					<tr>
            			<th>前台显示数据</th>
						<td>
							<textarea name='viewvalue'  style="float: left;width:380px; height:60px; vertical-align: middle;">{$config.viewvalue}</textarea>
							<span class="desc" style="height: 60px;float:left; background:none;padding-left: 5px;"><font color="#737C93">
								下拉列表框：1|男,2|女 说明:1,2为option的value值 男,女为提示文本<br/>
								单选框：1|男,2|女 说明:1,2为value值 男,女为提示文本<br/>
								复选框：1|男,2|女 说明:1,2为value值 男,女为提示文本<br />
								<font style='color:red'>请使用英文标点</font></font></span>
						</td>
            		</tr>
					<tr>
            			<th>默认值</th>
						<td>
							<input type='text' name='value' value='{$config.value}'/>
							<span class="desc"><font color="#737C93">默认值:如果是下拉框、单复选框，填入的默认值必须是|前的数值,复选框默认值有多个<font style='color:red'>以英文逗号隔开</font></font></span>
						</td>
            		</tr>
					<tr>
            			<th>提示信息</th>
						<td>
							<textarea name='msg'  style="float: left;width:380px; height:60px; vertical-align: middle;">{$config.msg}</textarea>
							<span class="desc" style="margin-top:40px;float:left; background:none;padding-left: 5px;"><font color="#737C93">
								配置项的提示文字，中文看的更清楚</font></span>
						</td>
            		</tr>
				</table>
			</div>
			<input type='hidden' name='id' value='{$config.id}' />
			<input type="submit" class="submit" value="修改配置项" name='submit'/>
			</form>
        </div>
		<script type='text/javascript'>
		var validator = new FormValidator('config', [{
		    name: 'tid',
		    display: '配置组',    
		    rules: 'required'
		},{
    		name: 'name',
			display: '配置项名称',
    		rules: 'required|alpha'
		},{
    		name: 'title',
			display: '配置项标题',
    		rules: 'required'
		},{
			name:'viewtype',
			display:'配置类型',
			rules:'required'
		},{
			name:'viewvalue',
			display:'前台显示数据',
			rules:'callback_check_viewvalue'
		}
		], function(errors, event) {
		    var SELECTOR_ERRORS = $('.error_box'),
		        SELECTOR_SUCCESS = $('.success_box');
		        
			    if (errors.length > 0) {
			        SELECTOR_ERRORS.empty();
			        
			        for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
			            SELECTOR_ERRORS.append(errors[i].message + '<br />');
			        }
			        
			        SELECTOR_SUCCESS.css({ display: 'none' });
			        SELECTOR_ERRORS.fadeIn(200);
			    } else {
			        SELECTOR_ERRORS.css({ display: 'none' });
			        SELECTOR_SUCCESS.fadeIn(200);
			    }
			    
			    if (event && event.preventDefault) {
			        event.preventDefault();
			    } else if (event) {
			        event.returnValue = false;
			    }
		});
		validator.registerCallback('check_viewvalue', function(value) {
			alert(value);
    		if($("select[name='viewtype']").val() == 'radio' ||  $("select[name='viewtype']").val() == 'checkbox'){
				if(value == ''){
					return false;
				}else{
					return true;
				}
			}
			})
			.setMessage('check_email', '*当配置类型为单选框或者复选框时，前台显示数据必填');
	</script>
    </body>
</html>